var Military_SOM = 0; // 0 = Self , 1 = Enemy

function Clipboard_Military() {

var Military_Armies = 6; // 0,1,2,3,4,5

var Military_Province_Name = prefService.getCharPref('extensions.Ultima.YourThroneProvinceName' );
var Military_Kingdom       = prefService.getIntPref('extensions.Ultima.YourThronekingdom'       );
var Military_Island        = prefService.getIntPref('extensions.Ultima.YourThroneisland'        );

var Military_Title = "";
var Military_Ruler_Name = "";
var Military_Personality = 0;
var Military_Race = 0;
var Military_Raw = 0;
var Military_Total_Captured_Land = 0;
var Military_Total_Summary_MEO = 0;
var Military_Total_Summary_MED = 0;
var Military_Offensive_Points = 0;
var Military_Defensive_Points = 0;
var Military_Non_Peasants = 0;
var Military_MEO = 0;
var Military_MED = 0;

var Military_Training_Offensive_Units = 0;
var Military_Training_Defensive_Units = 0;
var Military_Training_Elite_Units     = 0;
var Military_Training_Thieves         = 0;

var Military_Training_Offensive_Units_MEO = 0;
var Military_Training_Defensive_Units_MED = 0;
var Military_Training_Elite_Units_MEO     = 0;
var Military_Training_Elite_Units_MED     = 0;

var Military_General             = new Array(Military_Armies);
var Military_Soldiers            = new Array(Military_Armies); 
var Military_Soldiers_MEO        = new Array(Military_Armies); 
var Military_Soldiers_MED        = new Array(Military_Armies); 
var Military_Offensive_Units     = new Array(Military_Armies); 
var Military_Defensive_Units     = new Array(Military_Armies); 
var Military_Offensive_Units_MEO = new Array(Military_Armies); 
var Military_Defensive_Units_MED = new Array(Military_Armies); 
var Military_Elite_Units         = new Array(Military_Armies); 
var Military_Elite_Units_MEO     = new Array(Military_Armies); 
var Military_Elite_Units_MED     = new Array(Military_Armies); 
var Military_War_Horses          = new Array(Military_Armies); 
var Military_War_Horses_MEO      = new Array(Military_Armies); 
var Military_Captured_Land       = new Array(Military_Armies); 
var Military_Total_MEO           = new Array(Military_Armies); 
var Military_Total_MED           = new Array(Military_Armies); 
var Military_Time                = new Array(Military_Armies); 

for (i=0; i<Military_Armies ; i++) {

Military_General[i]             = 0;
Military_Soldiers[i]            = 0;
Military_Soldiers_MEO[i]        = 0;
Military_Soldiers_MED[i]        = 0;
Military_Offensive_Units[i]     = 0;
Military_Defensive_Units[i]     = 0;
Military_Offensive_Units_MEO[i] = 0;
Military_Defensive_Units_MED[i] = 0;
Military_Elite_Units[i]         = 0;
Military_Elite_Units_MEO[i]     = 0;
Military_Elite_Units_MED[i]     = 0;
Military_War_Horses[i]          = 0;
Military_War_Horses_MEO[i]      = 0;
Military_Captured_Land[i]       = 0;
Military_Total_MEO[i]           = 0;
Military_Total_MED[i]           = 0;
Military_Time[i]                = 0;

}

if ( EL == 4 ) { Export_Line = Export_Line_Decryption(mytext);

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1);

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Province_Name      = ABC_Decryption( Export_Line.slice(0,Export_Line.indexOf("_")) );

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Kingdom            = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Island             = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Race               = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Offensive_Points   = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Defensive_Points   = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Raw                = Number( Export_Line.slice(0,Export_Line.indexOf("_")) )/10;
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Non_Peasants       = Number( Export_Line.slice(0,Export_Line.indexOf("_")) )/10;
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_MEO                = Number( Export_Line.slice(0,Export_Line.indexOf("_")) )/10;
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_MED                = Number( Export_Line.slice(0,Export_Line.indexOf("_")) )/10;

for (i=0; i<Military_Armies ; i++) {

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_General[i]         = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Soldiers[i]        = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Offensive_Units[i] = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Defensive_Units[i] = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Elite_Units[i]     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_War_Horses[i]      = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Captured_Land[i]   = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Time[i]            = Number( Export_Line.slice(0,Export_Line.indexOf("_")) )/100;

}

Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Training_Offensive_Units = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Training_Defensive_Units = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Training_Elite_Units     = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Training_Thieves         = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_SOM                      = Number( Export_Line.slice(0,Export_Line.indexOf("_")) );
Export_Line = Export_Line.slice(Export_Line.indexOf("_")+1); Military_Ruler_Name               = ABC_Decryption( Export_Line.slice(0) );

for (i=0; i<12 ; i++) if ( Military_Ruler_Name.indexOf( Personality_Search_Key[i] ) != -1 ) Military_Personality = i;

} else {

mytext = mytext.slice(mytext.indexOf("Net Worth/Acre"));

if ( mytext.indexOf("Our thieves listen in on a report") != -1 ) Military_SOM = 1;

if ( mytext.indexOf("Our thieves listen in on a report") == -1 ) {

Military_SOM = 0;

mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);
mytext = mytext.slice(mytext.indexOf(eol)+1);

}

if ( Military_SOM == 1 ) {

mytext = mytext.slice(mytext.indexOf("Our thieves listen in on a report from the Military Elders of")+62);
Military_Province_Name = mytext.slice(0,mytext.indexOf(" ("));
Military_Kingdom       = mytext.slice(mytext.indexOf("(")+1,mytext.indexOf(":"));
Military_Island        = mytext.slice(mytext.indexOf(":")+1,mytext.indexOf(")"));

mytext = mytext.slice(mytext.indexOf(")"));

mytext = mytext.slice(mytext.indexOf(eol)+1);

mytext = mytext.slice(mytext.indexOf(eol)+1);

}

Military_Ruler_Name = mytext.slice(0,mytext.indexOf(","));

for (i=0; i<12 ; i++) if ( Military_Ruler_Name.indexOf( Personality_Search_Key[i] ) != -1 ) Military_Personality = i;

mytext = mytext.replace(/,/g, "");
mytext = mytext.replace(/	/g, " ");
mytext = mytext.replace(/  /g, " ");

for (i=0; i<10 ; i++) if ( mytext.indexOf( Offensive_Specialist_Name[i] ) != -1 ) Military_Race = i;

Military_Offensive_Points = CB_Find( mytext, "Net Offensive Points at Home" , eol );
Military_Defensive_Points = CB_Find( mytext, "Net Defensive Points at Home" , eol );

Military_Offensive_Points = Number( Military_Offensive_Points );
Military_Defensive_Points = Number( Military_Defensive_Points );

Military_MEO  = CB_Find( mytext, "Offensive Military Effectiveness" , "%" );
Military_MED  = CB_Find( mytext, "Defensive Military Effectiveness" , "%" );
Military_Raw  = CB_Find( mytext, "our military is functioning at"   , "%" );
Military_Non_Peasants = CB_Find( mytext, "approximately"            , "%" );

mytext = mytext.slice(mytext.indexOf("approximately "));
mytext = mytext.slice(mytext.indexOf("Standing Army"));
mytext = mytext.slice(mytext.indexOf(" ")+1);
mytext = mytext.slice(mytext.indexOf(" ")+1);

temp = mytext.slice(0,mytext.indexOf( "Soldiers " ));

for (i=1; i<Military_Armies ; i++) {
Military_General[i]=temp.charAt(0);
if ( Military_General[i] == "A" ) { Military_General[i] = 1; } else { Military_General[i] = 0; }
if ( Military_General[i] == 1 ) { Military_Time[i]=temp.slice(temp.indexOf("(")+1,temp.indexOf("days left)")-1); temp=temp.slice(temp.indexOf("days left")); }
temp = temp.slice(temp.indexOf(" ")+1);
temp = temp.slice(temp.indexOf(" ")+1);
}

Military_General[0] = 1;

temp = mytext.slice(mytext.indexOf( "Generals " )); temp = temp.slice(0,temp.indexOf(eol)); temp += " ";
for (i=0; i<Military_Armies ; i++) { temp = temp.slice(temp.indexOf(" ")+1); if ( Military_General[i] != 0) Military_General[i]         = temp.slice(0,temp.indexOf(" ")); } temp = mytext.slice(mytext.indexOf( "Soldiers "                                    )); temp = temp.slice( temp.indexOf(" ")                              ); temp = temp.slice(0,temp.indexOf(eol)); temp += " ";
for (i=0; i<Military_Armies ; i++) { temp = temp.slice(temp.indexOf(" ")+1); if ( Military_General[i] != 0) Military_Soldiers[i]        = temp.slice(0,temp.indexOf(" ")); } temp = mytext.slice(mytext.indexOf( Offensive_Specialist_Name[Military_Race] + " " )); temp = temp.slice( Offensive_Specialist_Name[Military_Race].length); temp = temp.slice(0,temp.indexOf(eol)); temp += " ";
for (i=0; i<Military_Armies ; i++) { temp = temp.slice(temp.indexOf(" ")+1); if ( Military_General[i] != 0) Military_Offensive_Units[i] = temp.slice(0,temp.indexOf(" ")); } temp = mytext.slice(mytext.indexOf( Defensive_Specialist_Name[Military_Race] + " " )); temp = temp.slice( Defensive_Specialist_Name[Military_Race].length); temp = temp.slice(0,temp.indexOf(eol)); temp += " ";
for (i=0; i<Military_Armies ; i++) { temp = temp.slice(temp.indexOf(" ")+1); if ( Military_General[i] != 0) Military_Defensive_Units[i] = temp.slice(0,temp.indexOf(" ")); } temp = mytext.slice(mytext.indexOf( Elite_Unit_Name[Military_Race]           + " " )); temp = temp.slice(           Elite_Unit_Name[Military_Race].length); temp = temp.slice(0,temp.indexOf(eol)); temp += " ";
for (i=0; i<Military_Armies ; i++) { temp = temp.slice(temp.indexOf(" ")+1); if ( Military_General[i] != 0) Military_Elite_Units[i]     = temp.slice(0,temp.indexOf(" ")); } temp = mytext.slice(mytext.indexOf( "War Horses "                                  )); temp = temp.slice( temp.indexOf("Horses")                         ); temp = temp.slice(temp.indexOf(" ")); temp = temp.slice(0,temp.indexOf(eol)); temp += " ";
for (i=0; i<Military_Armies ; i++) { temp = temp.slice(temp.indexOf(" ")+1); if ( Military_General[i] != 0) Military_War_Horses[i]      = temp.slice(0,temp.indexOf(" ")); } temp = mytext.slice(mytext.indexOf( "Captured Land "                               )); temp = temp.slice( temp.indexOf("Land")                           ); temp = temp.slice(temp.indexOf(" ")); temp = temp.slice(0,temp.indexOf(eol)); temp += " ";
for (i=0; i<Military_Armies ; i++) { temp = temp.slice(temp.indexOf(" ")+1); if ( Military_General[i] != 0) Military_Captured_Land[i]   = temp.slice(0,temp.indexOf(" ")); }

Military_Captured_Land[0] = 0;

for (i=1; i<Military_Armies ; i++) Military_Defensive_Units[i] = 0;


for (i=0; i<Military_Armies ; i++) {


Military_General[i]         = Number( Military_General[i]         );
Military_Soldiers[i]        = Number( Military_Soldiers[i]        );
Military_Offensive_Units[i] = Number( Military_Offensive_Units[i] );
Military_Defensive_Units[i] = Number( Military_Defensive_Units[i] );
Military_Elite_Units[i]     = Number( Military_Elite_Units[i]     );
Military_War_Horses[i]      = Number( Military_War_Horses[i]      );
Military_Captured_Land[i]   = Number( Military_Captured_Land[i]   );

}


mytext = mytext.slice(mytext.indexOf( "for the next 24 days." )); mytext = mytext.slice(mytext.indexOf(eol)+1);

mytext = mytext.slice(mytext.indexOf(eol)+1);
temp = mytext.slice(mytext.indexOf( Offensive_Specialist_Name[Military_Race] + " " )); temp = temp.slice(0,temp.indexOf(eol)+1);
temp = temp.slice(Offensive_Specialist_Name[Military_Race].length);
for (i=0; i<24 ; i++) { temp = temp.slice(temp.indexOf(" ")+1); Military_Training_Offensive_Units += Number( temp.slice(0,temp.indexOf(" ")) ); }

mytext = mytext.slice(mytext.indexOf(eol)+1);
temp = mytext.slice(mytext.indexOf( Defensive_Specialist_Name[Military_Race] + " " )); temp = temp.slice(0,temp.indexOf(eol)+1);
temp = temp.slice(Defensive_Specialist_Name[Military_Race].length);
for (i=0; i<24 ; i++) { temp = temp.slice(temp.indexOf(" ")+1); Military_Training_Defensive_Units += Number( temp.slice(0,temp.indexOf(" ")) ); }

mytext = mytext.slice(mytext.indexOf(eol)+1);
temp = mytext.slice(mytext.indexOf( Elite_Unit_Name[Military_Race] + " " )); temp = temp.slice(0,temp.indexOf(eol)+1);
temp = temp.slice(Elite_Unit_Name[Military_Race].length);
for (i=0; i<24 ; i++) { temp = temp.slice(temp.indexOf(" ")+1); Military_Training_Elite_Units     += Number( temp.slice(0,temp.indexOf(" ")) ); }

mytext = mytext.slice(mytext.indexOf(eol)+1);
temp = mytext.slice(mytext.indexOf( "Thieves " )); temp = temp.slice(0,temp.indexOf(eol)+1);
temp = temp.slice(7);
for (i=0; i<24 ; i++) { temp = temp.slice(temp.indexOf(" ")+1); Military_Training_Thieves         += Number( temp.slice(0,temp.indexOf(" ")) ); }

}

Export_Line = "_964_"+ABC_Encryption(Military_Province_Name);

Export_Line += "_"+ Military_Kingdom          ;
Export_Line += "_"+ Military_Island           ;
Export_Line += "_"+ Military_Race             ;
Export_Line += "_"+ Military_Offensive_Points ;
Export_Line += "_"+ Military_Defensive_Points ;
Export_Line += "_"+ Math.round( Military_Raw * 10 ) ;
Export_Line += "_"+ Math.round( Military_Non_Peasants * 10 ) ;
Export_Line += "_"+ Math.round( Military_MEO * 10 ) ;
Export_Line += "_"+ Math.round( Military_MED * 10 ) ;

for (i=0; i<Military_Armies ; i++) {

Export_Line += "_"+ Military_General[i];
Export_Line += "_"+ Military_Soldiers[i];
Export_Line += "_"+ Military_Offensive_Units[i];
Export_Line += "_"+ Military_Defensive_Units[i];
Export_Line += "_"+ Military_Elite_Units[i];
Export_Line += "_"+ Military_War_Horses[i];
Export_Line += "_"+ Military_Captured_Land[i];
Export_Line += "_"+ Math.round( Military_Time[i] * 100 ) ;

}

Export_Line += "_"+ Military_Training_Offensive_Units;
Export_Line += "_"+ Military_Training_Defensive_Units;
Export_Line += "_"+ Military_Training_Elite_Units;
Export_Line += "_"+ Military_Training_Thieves;
Export_Line += "_"+ Military_SOM;
Export_Line += "_"+ ABC_Encryption(Military_Ruler_Name);

if ( Military_SOM == 0 ) Military_Title = "Military Intel on ";
if ( Military_SOM == 1 ) Military_Title = "Military Intelligence on ";

Military_Title += Military_Province_Name+" ("+ Military_Kingdom +":"+ Military_Island +")";

for (i=0; i<Military_Armies ; i++) {

Military_Soldiers_MEO[i]        = Math.round( Military_Soldiers[i]        * Offensive_Soldiers_Strength[Military_Race]   * Military_MEO / 100 ) ;
Military_Soldiers_MED[i]        = Math.round( Military_Soldiers[i]        * Defensive_Soldiers_Strength[Military_Race]   * Military_MED / 100 ) ;
Military_Offensive_Units_MEO[i] = Math.round( Military_Offensive_Units[i] * Offensive_Specialist_Strength[Military_Race] * Military_MEO / 100 ) ;
Military_Defensive_Units_MED[i] = Math.round( Military_Defensive_Units[i] * Defensive_Specialist_Strength[Military_Race] * Military_MED / 100 ) ;
Military_Elite_Units_MEO[i]     = Math.round( Military_Elite_Units[i]     * Offensive_Elite_Unit_Strength[Military_Race] * Military_MEO / 100 ) ;
Military_Elite_Units_MED[i]     = Math.round( Military_Elite_Units[i]     * Defensive_Elite_Unit_Strength[Military_Race] * Military_MED / 100 ) ;

Military_War_Horses_MEO[i] = Military_War_Horses[i] ;
if ( Military_War_Horses[i] > Military_Soldiers[i] + Military_Offensive_Units[i] + Military_Elite_Units[i] ) Military_War_Horses_MEO[i] = Military_Soldiers[i] + Military_Offensive_Units[i] + Military_Elite_Units[i] ;
Military_War_Horses_MEO[i] = Math.round( Military_War_Horses_MEO[i] * Military_MEO / 100 ) ;

Military_Total_MEO[i] = Military_Soldiers_MEO[i] + Military_Offensive_Units_MEO[i] + Military_Elite_Units_MEO[i] + Military_War_Horses_MEO[i];
Military_Total_MED[i] = Military_Soldiers_MED[i] + Military_Defensive_Units_MED[i] + Military_Elite_Units_MED[i];

}

Military_Total_Summary_MEO   = 0;
Military_Total_Summary_MED   = 0;
Military_Total_Captured_Land = 0;

for (i=0; i<Military_Armies ; i++) {

Military_Total_Summary_MEO   += Military_Total_MEO[i] ;
Military_Total_Summary_MED   += Military_Total_MED[i] ;
if ( i > 0 ) Military_Total_Captured_Land += Military_Captured_Land[i] ;

}

Military_Training_Offensive_Units_MEO = Math.round( Military_Training_Offensive_Units * Offensive_Specialist_Strength[Military_Race] * Military_MEO / 100 ) ;
Military_Training_Defensive_Units_MED = Math.round( Military_Training_Defensive_Units * Defensive_Specialist_Strength[Military_Race] * Military_MED / 100 ) ;
Military_Training_Elite_Units_MEO     = Math.round( Military_Training_Elite_Units     * Offensive_Elite_Unit_Strength[Military_Race] * Military_MEO / 100 ) ;
Military_Training_Elite_Units_MED     = Math.round( Military_Training_Elite_Units     * Defensive_Elite_Unit_Strength[Military_Race] * Military_MED / 100 ) ;


/////////////////////////
// Military Calculator //
/////////////////////////

var Military_Peasants = Math.round( ( Military_Defensive_Points - Military_Total_MED[0] ) * 400 / Military_MED );

if ( Military_Peasants < 1 ) Military_Peasants = 0 ;

if ( Military_Peasants > 0 ) prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyPeasantsBox'   , true  );

prefService.setCharPref('extensions.Ultima.MilitaryCalculatorEnemyProvinceName'  , Military_Province_Name +" ("+ Military_Kingdom +":"+ Military_Island + ")" );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyRace'          , Military_Race );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyPersonality'   , Military_Personality );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyRelations'     , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyStance'        , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyDragon'        , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemySoldiers'      , Military_Soldiers[0] );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyOffSpecs'      , Military_Offensive_Units[0] );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyDefSpecs'      , Military_Defensive_Units[0] );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyElites'        , Military_Elite_Units[0] );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyLand'          , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyNW'            , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyKDNW'          , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyOME'           , Military_MEO * 1000000 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyDME'           , Military_MED * 1000000 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyGenerals'      , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyAttackTime'    , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyHorses'        , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyMerc'          , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyPris'          , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyMilitarySci'   , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyRecentlyHit'   , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyGuardStation'  , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyPeasants'      , Military_Peasants );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyRawME'         , Military_Raw );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyBE'            , 100 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyTG'            , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyForts'         , 0 );
prefService.setIntPref( 'extensions.Ultima.MilitaryCalculatorEnemyRank'          , 2 );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyFanaticismBox' , false );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyAggressionBox' , false );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyProtectionBox' , true  );
prefService.setBoolPref('extensions.Ultima.MilitaryCalculatorEnemyPlagueBox'     , false );



/////////////////////////
// Military Calculator //
/////////////////////////


for (i=0; i<Military_Armies ; i++) {

Military_Soldiers_MEO[i]        = Add_Commas( Military_Soldiers_MEO[i]        );
Military_Soldiers_MED[i]        = Add_Commas( Military_Soldiers_MED[i]        );
Military_Offensive_Units_MEO[i] = Add_Commas( Military_Offensive_Units_MEO[i] );
Military_Defensive_Units_MED[i] = Add_Commas( Military_Defensive_Units_MED[i] );
Military_Elite_Units_MEO[i]     = Add_Commas( Military_Elite_Units_MEO[i]     );
Military_Elite_Units_MED[i]     = Add_Commas( Military_Elite_Units_MED[i]     );
Military_War_Horses_MEO[i]      = Add_Commas( Military_War_Horses_MEO[i]      );

}

Military_Offensive_Points       = Add_Commas( Military_Offensive_Points       );
Military_Defensive_Points       = Add_Commas( Military_Defensive_Points       );
Military_Total_Summary_MEO      = Add_Commas( Military_Total_Summary_MEO      );
Military_Total_Summary_MED      = Add_Commas( Military_Total_Summary_MED      );
Military_Total_Captured_Land    = Add_Commas( Military_Total_Captured_Land    );

Military_Training_Offensive_Units = Add_Commas( Military_Training_Offensive_Units );
Military_Training_Defensive_Units = Add_Commas( Military_Training_Defensive_Units );
Military_Training_Elite_Units     = Add_Commas( Military_Training_Elite_Units     );
Military_Training_Thieves         = Add_Commas( Military_Training_Thieves         );





for (i=1; i<Military_Armies ; i++) {

var Military_Time_Hour = Math.floor(Military_Time[i]);
var Military_Time_Mins = Math.round((Military_Time[i]-Military_Time_Hour)*60);

if ( Military_Time_Mins < 10 ) Military_Time_Mins = "0" + Military_Time_Mins ;

Military_Time[i] = Military_Time_Hour +":"+ Military_Time_Mins ;

}




function Military_Army_Str(str,i) {

if ( i == 0 ) str = "<br /><br />"+c0+"** Standing Army (At Home) **"+cc;
if ( i != 0 ) str = "<br /><br />"+c0+"** Army "+str+" (Back in " +Military_Time[i]+" hours) **"+cc;

var off_bonus_str = "no";

if ( Military_General[i] > 1 ) off_bonus_str = "+" + Math.round((Military_General[i]-1)*3) + "%" ;

str += "<br />"+c1+"Generals: "+cc+c2+Military_General[i]+cc+c1+" ("+ off_bonus_str +" offense bonus)"+cc;

if ( Military_Soldiers[i]        > "0" ) { Military_Soldiers[i]            = Add_Commas( Military_Soldiers[i]            ); str += "<br />"+c1+"Soldiers: "+cc+c2+Military_Soldiers[i]+cc+c1+" ("+Military_Soldiers_MEO[i]+" offense / "+Military_Soldiers_MED[i]+" defense)"+cc; }
if ( Military_Offensive_Units[i] > "0" ) { Military_Offensive_Units[i]     = Add_Commas( Military_Offensive_Units[i]     ); str += "<br />"+c1+Offensive_Specialist_Name[Military_Race]+": "+cc+c2+Military_Offensive_Units[i]+cc+c1+" ("+Military_Offensive_Units_MEO[i]+" offense)"+cc; }
if ( Military_Defensive_Units[i] > "0" ) { Military_Defensive_Units[i]     = Add_Commas( Military_Defensive_Units[i]     ); str += "<br />"+c1+Defensive_Specialist_Name[Military_Race]+": "+cc+c2+Military_Defensive_Units[i]+cc+c1+" ("+Military_Defensive_Units_MED[i]+" defense)"+cc; }
if ( Military_Elite_Units[i]     > "0" ) { Military_Elite_Units[i]         = Add_Commas( Military_Elite_Units[i]         ); str += "<br />"+c1+Elite_Unit_Name[Military_Race]          +": "+cc+c2+Military_Elite_Units[i]+cc+c1+" ("+Military_Elite_Units_MEO[i]+" offense / "+Military_Elite_Units_MED[i]+" defense)"+cc; }
if ( Military_War_Horses[i]      > "0" ) { Military_War_Horses[i]          = Add_Commas( Military_War_Horses[i]          ); str += "<br />"+c1+"War-Horses: "+cc+c2+Military_War_Horses[i]+cc+c1+" (up to "+Military_War_Horses_MEO[i]+" additional offense)"+cc; }
if ( Military_Total_MEO[i]       > "0" ) { Military_Total_MEO[i]           = Add_Commas( Military_Total_MEO[i]           ); str += "<br />"+c1+"Total Attack points: "+cc+c2+Military_Total_MEO[i]+cc; }
if (( Military_SOM == 1 )||( i == 0 )) if ( Military_Total_MED[i]       > "0" ) { Military_Total_MED[i]           = Add_Commas( Military_Total_MED[i]           ); str += "<br />"+c1+"Total Defense points: "+cc+c2+Military_Total_MED[i]+cc; }
if ( Military_Captured_Land[i]   > "0" ) { Military_Captured_Land[i]       = Add_Commas( Military_Captured_Land[i]       ); str += "<br />"+c1+"Captured Land: "+cc+c2+Military_Captured_Land[i]+cc+c1+" Acres"+cc; }

return str;

}

var Military_Army_String = new Array(Military_Armies);

for (i=0; i<Military_Armies ; i++) Military_Army_String[i] = "";


Military_Army_String[0] = Military_Army_Str( "" ,0);



var Astr = "";

for (i=1; i<Military_Armies ; i++) {

Astr = "#"+Math.round(i+1) ; 

if ( Military_General[i] > 0 ) Military_Army_String[i] = Military_Army_Str( Astr ,i);

}







textonly=c0+Military_Title+cc+Copyrights+

"<br />"+c1+"Ruler Name: "+cc+c2+Military_Ruler_Name+cc+
"<br />"+c1+"Personality & Race: "+cc+c2+"The "+Personality_Name[Military_Personality]+", "+Race_Name[Military_Race]+cc+
"<br /><br />"+c0+"** Summary **"+cc+
"<br />"+c1+"Non-Peasants: "+cc+c2+Military_Non_Peasants +cc+c1+"%"+cc+
"<br />"+c1+"Efficiency (SoM): "+cc+c2+Military_MEO+cc+c1+"% off., "+cc+c2+Military_MED+cc+c1+"% def., "+cc+c2+Military_Raw+cc+c1+"% raw"+cc+
"<br />"+c1+"Net Offense at Home (from Utopia): "+cc+c2+Military_Offensive_Points+cc+
"<br />"+c1+"Net Defense at Home (from Utopia): "+cc+c2+Military_Defensive_Points+cc+
"<br />"+c1+"Modified Attack points (calculated): "+cc+c2+Military_Total_Summary_MEO+cc+
"<br />"+c1+"Modified Defense points (calculated): "+cc+c2+Military_Total_Summary_MED+cc;

if ( Military_Total_Captured_Land != "0") textonly += "<br />"+c1+"Total Captured Land: "+cc+c2+Military_Total_Captured_Land+cc;

for (i=0; i<Military_Armies ; i++) textonly += Military_Army_String[i];

if (( Military_Training_Offensive_Units != "0" )||( Military_Training_Defensive_Units != "0" )||( Military_Training_Elite_Units != "0" )||( Military_Training_Thieves != "0" )) textonly += "<br /><br />"+c0+"** Troops in Training **"+cc;
if ( Military_Training_Offensive_Units != "0" ) textonly += "<br />"+c1+ Offensive_Specialist_Name[Military_Race] +": "+cc+c2+ Military_Training_Offensive_Units +cc+c1+" ("+ Military_Training_Offensive_Units_MEO +" offense)"+cc;
if ( Military_Training_Defensive_Units != "0" ) textonly += "<br />"+c1+ Defensive_Specialist_Name[Military_Race] +": "+cc+c2+ Military_Training_Defensive_Units +cc+c1+" ("+ Military_Training_Defensive_Units_MED +" defense)"+cc;
if ( Military_Training_Elite_Units     != "0" ) textonly += "<br />"+c1+ Elite_Unit_Name[Military_Race]           +": "+cc+c2+ Military_Training_Elite_Units     +cc+c1+" ("+ Military_Training_Elite_Units_MEO     +" offense/"+ Military_Training_Elite_Units_MED +" defense)"+cc;
if ( Military_Training_Thieves         != "0" ) textonly += "<br />"+c1+"Thieves: "+cc+c2+ Military_Training_Thieves +cc;

textonly += "<br />";

formated_text = textonly;

textonly = textonly.replace(/<font color='#aa8822'>/g, "");
textonly = textonly.replace(/<font>/g, "");
textonly = textonly.replace(/<font color='#888888'>/g, "");
textonly = textonly.replace(/<font color='#ff0000'>/g, "");
textonly = textonly.replace(/<\/font>/g, "");
textonly = textonly.replace(/<br \/>/g, String.fromCharCode(13,10));

formated_copy = textonly;

formated_copy += String.fromCharCode(13,10) + "** Export Line [ver 1] -- Military [ver 1]: **" + String.fromCharCode(13,10) + Export_Line_Encryption(Export_Line);

}